Skip to content

Updated functionality#50

Open
ianthehamster wants to merge 3 commits into
rocketacademy:mainfrom
ianthehamster:main
Open

Updated functionality#50
ianthehamster wants to merge 3 commits into
rocketacademy:mainfrom
ianthehamster:main

Conversation

@ianthehamster

Copy link
Copy Markdown

No description provided.

Comment thread src/App.js
constructor() {
super();
this.state = {
apiKey: "db2b631c79deae1500162a294faec7dc",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never commit your API key. This should be in your .env file. Please revise https://bootcamp.rocketacademy.co/2-full-stack/2.2-advanced-react/2.2.7-environmental-variables

This is a big security risk and could potentially cost you thousands of dollars if it was another payable API.

Comment thread src/App.js
)
.then((res) => {
this.setState({
img: res.config.url,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? Since you do not return the axios request's result in the previous then block, I do not think this would work.

Comment thread src/App.js
console.log(weatherData.list);

for (const el of weatherData.list) {
this.state.output.push(el.dt_txt);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you directly push into a state variable. You should only use the setState function for this, and never directly update a state variable. This can lead to erratic behaviour in your app.

Comment thread src/App.js

renderTable() {
const data = this.state.output;
if (!data || data.length === 0) return null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!data || data.length === 0) return null;
if (!data) return null;

same thing

Comment thread src/App.js Outdated
/> */}

{/* <input type="submit" value="submit" onClick={this.handleSubmit} /> */}
{this.state.img !== "" ? (

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{this.state.img !== "" ? (
{this.state.img ? (

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants